package com.jt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jt.mapper.StorageMapper;
import com.jt.pojo.Storage;
import com.jt.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StorageServiceImpl extends ServiceImpl<StorageMapper, Storage> implements StorageService {

    @Autowired
    private StorageMapper storageMapper;

    @Override
    public boolean StorageDelete(int count, int StorageId) {
        Storage storage = storageMapper.selectById(StorageId);
        storage.setCount(storage.getCount() - count);
        int counts = storageMapper.update(storage, new QueryWrapper<Storage>().eq("id", StorageId));
        if (counts>0){
            return  true;
        }else {
            return  false;
        }
    }
}
